package databases

import (
	"errors"
	"github.com/go-xorm/xorm"
	"gitlab.gaodun.com/golib/gderror"
	"permission/config"
	"permission/vigo_loger"
)

type HomePageFactory struct {
	Table        Tpo_Sys_HomePage_Config
	engine       *xorm.Engine
	RowsSlicePtr []Tpo_Sys_HomePage_Config
}

// 返回 user factory
func NewHomePageFactory() *HomePageFactory {
	homeFac := HomePageFactory{}
	homeFac.engine, _ = config.InitEng()
	return &homeFac
}

func (hgf *HomePageFactory) GetInfoByUidAndAppId(userId int64, appId int32) (bool, error) {
	if userId == 0 || appId == 0 {
		return false, errors.New("user and app id nil")
	}
	ok, err := hgf.engine.Where(" user_id = ? and AppId = ? ", userId, appId).Get(&(hgf.Table))
	if err != nil {
		vigo_loger.AddGrayLog(gderror.New(err.Error()).Error())
	}
	return ok, err
}
